import asyncio
import time
async def func1():
    print("你好，张发富")
    # time.sleep(3)   #当程序出现同步操作的时候，异步就中断了
    await asyncio.sleep(3)  # 异步操作代码
    print("你好，张发富")

async def func2():
    print("你好，王建国")
    # time.sleep(3)
    await asyncio.sleep(2)
    print("你好，王建国")

async def func3():
    print("你好，李雪琴")
    # time.sleep(3)
    await asyncio.sleep(4)
    print("你好，李雪琴")

if __name__ == '__main__':
    f1 = func1()
    f2 = func2()
    f3 = func3()
    tasks = [
        f1,f2,f3
    ]
    t1 = time.time()
    # 一次性启动多个任务（协程）
    asyncio.run(asyncio.wait(tasks)) #基本不变

    t2 = time.time()
    print(t2-t1)